home *** CD-ROM | disk | FTP | other *** search
- Path: abcfd20.larc.nasa.gov!amiga-request
- From: amiga-request@abcfd20.larc.nasa.gov (Amiga Sources/Binaries Moderator)
- Subject: v90i269: ezlib - a library of functions; make programming easier, Part01/02
- Reply-To: nick@chopin.uucp (Dominic Giampaolo)
- Newsgroups: comp.sources.amiga
- Message-ID: <comp.sources.amiga:v90i269@abcfd20.larc.nasa.gov>
- Date: 10 Oct 90 00:59:54 GMT
- Approved: tadguy@uunet.UU.NET (Tad Guy)
- X-Mail-Submissions-To: amiga@uunet.uu.net
- X-Post-Discussions-To: comp.sys.amiga
-
- Submitted-by: nick@chopin.uucp (Dominic Giampaolo)
- Posting-number: Volume 90, Issue 269
- Archive-name: libraries/ezlib/part01
-
- [ uuencoded library and executable enclosed ...tad ]
-
- Here is a link time library I have written. This library makes
- writing programs that access Amiga specific features somewhat easier.
- There are readme files that go into more detail in the archive.
- Essentially the library provides abstract access to the creation of
- screens, window, and boolean gadgets (and some other things) - i.e.
- you don't have to worry about all the gory details any more.
-
- #!/bin/sh
- # This is a shell archive. Remove anything before this line, then unpack
- # it by saving it into a file and typing "sh file". To overwrite existing
- # files, type "sh file -c". You can also feed this as standard input via
- # unshar, or by typing "sh <file", e.g.. If this archive is complete, you
- # will see the following message at the end:
- # "End of archive 1 (of 2)."
- # Contents: README demo_src demo_src/frac demo_src/frac/frac.c
- # demo_src/frac/makefile demo_src/sin demo_src/sin/makefile
- # demo_src/sin/sin.c doc doc/closelibs.doc doc/create_boolgadget.doc
- # doc/createwindow.doc doc/defines.doc doc/free_bitmap.doc
- # doc/getbitmap.doc doc/getfont.doc doc/getstring.doc doc/getyn.doc
- # doc/killgadget.doc doc/killscreen.doc doc/killwindow.doc
- # doc/laced_wb.doc doc/makeboolgadget.doc doc/makescreen.doc
- # doc/makewindow.doc doc/openlibs.doc ezlib.h src src/ezlib.h
- # src/gadg.c src/gadget.c src/getfont.c src/getyn.c src/include
- # src/include/includes.h src/makefile src/openlibs.c src/window.c
- # Wrapped by tadguy@abcfd20 on Tue Oct 9 20:59:50 1990
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f 'README' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'README'\"
- else
- echo shar: Extracting \"'README'\" \(5223 characters\)
- sed "s/^X//" >'README' <<'END_OF_FILE'
- X Ez Lib
- X A link time library to make life easy
- X -------------------------------------
- X
- X Howdy. You have just gotten your greedy little hands on a library
- Xcalled Ez.lib. Ez.lib is a link time library which provides numerous calls
- Xto access many Intuition features without the normal hassle. There are
- Xsingle line calls to open any type of screen, window, or boolean gadget.
- X
- X This library is my effort at making the Amiga a little bit less of a
- Xbear to program. You can now do something like this:
- X
- X struct Screen *screen;
- X
- X screen = makescreen(HIRES|LACE, 4); /* 640x400x16 color */
- X if (screen == NULL)
- X error_no_screen();
- X
- X As you can see from the above code, you will save yourself HOURS of
- Xtime with a single function call. No more hassling around worrying about
- XBitMap structures etc.... The makescreen() call will even check to make
- Xsure that Graphics.library and Intuition.library are opened. Working with
- Xscreens, windows, and boolean gadgets now becomes trivial.
- X
- X In addition there are two "widgets" in the library. The first widget
- Xis getyn(). It will simply return true or false depending on how the user
- Xclicked the AutoRequest(). NOTE: this function was taken from M. Dillon's
- XDME, however I did enhance it somewhat.
- X The other "widget", getstring() will pop open a small window to get a
- Xstring of input from the user. It is about as difficult to use as fgets()
- Xor similar - making it easy to create Intuitionized programs.
- X
- X For the more hacker types there are a few lower level functions
- Xwhich you can call if you wish. These provide access to properly allocated
- Xand filled in BitMaps, Gadgets, and other things.
- X
- X
- X
- X
- X Installing and Using Ez.lib
- X ---------------------------
- X
- X What do you have to do to use all these nifty and wonderful things?
- X
- X Not much. The included library is for Manx 3.6. If you have Manx 5.0
- Xyou will just have to recompile the modules and use LB to make the library.
- XYou can find out more about this by looking at the makefile in the SRC
- Xdirectory.
- X
- X If you have Lattice, you will have to recompile the modules and then
- Xuse whatever tool is provided with Lattice to make a link time library. I
- Xdon't have Lattice so I can't help you too much. Basically all there is in
- Xthe SRC directory is a bunch of individual source modules which need to be
- Xcompiled. Granted the code isn't ANSI C, but it should compile without too
- Xmany warnings (I hope ;^)
- X
- X After you have the correct version of the library, you simply need to
- Xput it where your compiler will find it. Same thing for the header file.
- XYou can just put these wherever your setup looks for them.
- X
- X Then, when you write a program that uses Ez.lib, you just
- X
- X #include <ezlib.h>
- X
- Xat the beginning of your program. When you get to the linking stage,
- Xsimply link with ez.lib (e.g. "ln -o demo demo.o -lez -lc") and you are
- Xdone. That's it, no more no less.
- X
- X
- X
- X
- X Other things of interest
- X ------------------------
- X
- X The full docs for each of the functions in Ez.lib are in the DOC
- Xdirectory. Poke around there for more info.
- X
- X The SRC directory just contains the individual files that provide the
- Xfunctionality. You can sniff through here if you don't trust my coding or
- Xto see if I did something wrong (hey, if I did I'd like to hear about it,
- Xas I certainly don't want trashy code floating around with my name on it :)
- X
- X The demo that is in the root level is just a simple demo which
- Xexercises each of the features in Ez.lib. As you can see it is less than
- X9K and does a fair amount. BTW, it looks for a font. If you don't have it
- Xit's no big deal, but just so you know.
- X
- X The DEMOS directory contains a few programs that show how to use the
- Xlibrary. They are all very simple, purposely, so that you can see how the
- Xlibrary is used.
- X
- X
- X
- X Final Notes
- X -----------
- X
- X At the moment the gadget creation facilities are somewhat plain. They
- Xjust create simple box affairs. I'm looking into changing this to a more
- X3-D'ish look. Don't worry though as the changes would be transparent to
- Xyou - they would just require a re-compile.
- X
- X I'm going to continue to add functionality to this library as needed.
- XI'd like access to string gadgets and ideally prop gadgets too (but I
- Xunderstand this is much easier in 2.0, so I may not bother). I'm probably
- Xgoing to add some Rexx code that I have written (to send/receive rexx
- Xmessages in an abstract way - i.e. send_rxmsg(string) ). I also have a few
- Xroutines to work with ARP, and chances are they will be in the next
- Xrelease too.
- X
- X I hope that this library will now make it easy for you to say - "Hey
- XI've got this neat idea, let me do it." Instead of (what I used to do)
- X"Aww man, it's too much hassle to open a {window,screen,gadget}".
- X
- X I would also like feedback on these routines and ways to improve them.
- XThey work fine for me, but maybe not for you. If so, lemme know.
- X
- X
- X--dominic giampaolo
- X Appt. # 8067 West
- X 4201 Mass. Ave.
- X Washington, D.C. 20016
- X
- XE-Mail : nick@chopin.uunet.uu.net >
- X or |
- X uunet!chopin!nick >---- preferred
- X or |
- X chopin!nick@uunet.uu.net >
- X or
- X giampal@auvm.bitnet
- X
- X
- END_OF_FILE
- if test 5223 -ne `wc -c <'README'`; then
- echo shar: \"'README'\" unpacked with wrong size!
- fi
- # end of 'README'
- fi
- if test ! -d 'demo_src' ; then
- echo shar: Creating directory \"'demo_src'\"
- mkdir 'demo_src'
- fi
- if test ! -d 'demo_src/frac' ; then
- echo shar: Creating directory \"'demo_src/frac'\"
- mkdir 'demo_src/frac'
- fi
- if test -f 'demo_src/frac/frac.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'demo_src/frac/frac.c'\"
- else
- echo shar: Extracting \"'demo_src/frac/frac.c'\" \(1451 characters\)
- sed "s/^X//" >'demo_src/frac/frac.c' <<'END_OF_FILE'
- X/* this program generates psuedo-fractal mountains using a
- X * random midpoint displacement algorithim (sounds fancy eh :)
- X *
- X * It is taken from Pokorny & Gerald, _Computer Graphics_ (the chapter
- X * on fractals)
- X *
- X * D.B.G. August 90.
- X */
- X#include <ezlib.h>
- X#include <math.h>
- X
- X#define MAX 640
- X
- X/* NOTE: It is **very** important to declare functions that return doubles
- X * as double. If not, Manx gleefully fucks up your code by converting
- X * everything to int.
- X */
- Xdouble ran();
- X
- Xdouble line[MAX];
- Xdouble rug = 0.3;
- Xstruct Screen *screen = NULL;
- X
- Xmain()
- X{
- X struct RastPort *rp;
- X int i, j;
- X double temp1;
- X
- X srand(time(0L)); /* I think this may be wrong here.... */
- X
- X line[0] = line[MAX-1] = (double) ((rand() % 50)+100); /* seed it */
- X
- X fracline(0, MAX-1); /* generate the "mountain" */
- X
- X screen = makescreen(HIRES, 2); /* get a custom screen */
- X if (screen == NULL)
- X { closelibs(); MSG("Opening Screen failed.\n"); exit(10); }
- X
- X rp = &screen->RastPort;
- X
- X Move(rp, 0L, (int) line[0]);
- X for (i=1; i < MAX; i++)
- X Draw(rp, i, (int) line[i]);
- X
- X Delay(100);
- X killscreen(screen);
- X closelibs();
- X
- X exit(0);
- X}
- X
- Xfracline(a, b)
- X int a, b;
- X{
- X register int mid;
- X double temp1, temp2;
- X
- X if ( (b - a) > 1 ) {
- X mid = (a + b) / 2;
- X
- X temp1 = (double) ((line[a] + line[b]) / 2);
- X temp2 = (ran() * 2.0) - 1.0;
- X temp2 = temp2 * ((double)(b - a)) * rug;
- X line[mid] = (double) (temp1 + temp2);
- X
- X fracline(a, mid);
- X fracline(mid, b);
- X }
- X}
- X
- X
- END_OF_FILE
- if test 1451 -ne `wc -c <'demo_src/frac/frac.c'`; then
- echo shar: \"'demo_src/frac/frac.c'\" unpacked with wrong size!
- fi
- # end of 'demo_src/frac/frac.c'
- fi
- if test -f 'demo_src/frac/makefile' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'demo_src/frac/makefile'\"
- else
- echo shar: Extracting \"'demo_src/frac/makefile'\" \(87 characters\)
- sed "s/^X//" >'demo_src/frac/makefile' <<'END_OF_FILE'
- Xfrac : frac.c
- X cc +L +Ivd0:include/header.h frac.c
- X ln +Q -o frac frac.o -lez -lm -lc
- X
- END_OF_FILE
- if test 87 -ne `wc -c <'demo_src/frac/makefile'`; then
- echo shar: \"'demo_src/frac/makefile'\" unpacked with wrong size!
- fi
- # end of 'demo_src/frac/makefile'
- fi
- if test ! -d 'demo_src/sin' ; then
- echo shar: Creating directory \"'demo_src/sin'\"
- mkdir 'demo_src/sin'
- fi
- if test -f 'demo_src/sin/makefile' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'demo_src/sin/makefile'\"
- else
- echo shar: Extracting \"'demo_src/sin/makefile'\" \(82 characters\)
- sed "s/^X//" >'demo_src/sin/makefile' <<'END_OF_FILE'
- Xsin : sin.c
- X cc +ff +L +Ivd0:include/header.h sin.c
- X ln -o sin sin.o -lez -lm -lc
- END_OF_FILE
- if test 82 -ne `wc -c <'demo_src/sin/makefile'`; then
- echo shar: \"'demo_src/sin/makefile'\" unpacked with wrong size!
- fi
- # end of 'demo_src/sin/makefile'
- fi
- if test -f 'demo_src/sin/sin.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'demo_src/sin/sin.c'\"
- else
- echo shar: Extracting \"'demo_src/sin/sin.c'\" \(3150 characters\)
- sed "s/^X//" >'demo_src/sin/sin.c' <<'END_OF_FILE'
- X/* This program draws Lissajous curves. It is taken directly from the
- X * chapter 3 exercises in a book called _Computer Graphics: The Principles
- X * Behind the Art and Science_. That book is written by Pokorny &
- X * Gerald.
- X *
- X * Believe it or not the Amiga is actually mentioned in that book! ;^)
- X */
- X
- X#include <stdio.h>
- X#include <math.h>
- X#include <ezlib.h>
- X
- X#define MAX 320
- X
- Xdouble sin_tab[360], cos_tab[360];
- X
- X/* first we allocate two screens, set up some colors and make sure that
- X * all worked.
- X *
- X * Then we fill in a table so we don't have keep calling the sin() function
- X * when draw the actual curves.
- X *
- X * Finally we scroll the picture off the screen using a simple double
- X * buffering technique.
- X */
- X
- Xmain()
- X{
- X register int i;
- X int j, count = 0;
- X double ang, step, hold_x, hold_y;
- X struct Screen *screen1, *screen2;
- X struct BitMap *bm1, *bm2;
- X struct RastPort *rp, *rp2;
- X
- X screen2 = makescreen(HIRES, 3);
- X if (screen2 == NULL)
- X exit(10L);
- X
- X setcolor(screen2, 0, BLACK); setcolor(screen2, 1, WHITE);
- X setcolor(screen2, 2, BLUE); setcolor(screen2, 5, GREEN);
- X setcolor(screen2, 3, PINK); setcolor(screen2, 4, ORANGE);
- X setcolor(screen2, 6, GREY); setcolor(screen2, 7, RED);
- X
- X screen1 = makescreen(HIRES, 3);
- X if (screen1 == NULL)
- X { killscreen(screen2); exit(10L); }
- X
- X setcolor(screen1, 0, BLACK); setcolor(screen1, 1, WHITE);
- X setcolor(screen1, 2, BLUE); setcolor(screen1, 5, GREEN);
- X setcolor(screen1, 3, PINK); setcolor(screen1, 4, ORANGE);
- X setcolor(screen1, 6, GREY); setcolor(screen1, 7, RED);
- X
- X rp = &screen1->RastPort; rp2 = &screen2->RastPort;
- X bm1 = &screen1->BitMap; bm2 = &screen2->BitMap;
- X
- X /* this loop fills up a table with a sine curve */
- X /* the magic number 0.01745 is radians per degree */
- X for(i=0; i < 360; i++) {
- X sin_tab[i] = sin(0.01745 * (double)i);
- X cos_tab[i] = cos(0.01745 * (double)i);
- X }
- X
- X step = (double)360 / (double)MAX;
- X Move(rp, 320, 100+90);
- X for(j=90; j > 30; j -= 2) {
- X ang = 0.0;
- X for(i=0; i < MAX; i++) {
- X hold_x = sin_tab[ (2 * (int)ang) % 360] * (double)j * 2.0;
- X hold_y = cos_tab[ (3 * (int)ang) % 360] * (double)j;
- X Draw(rp, 320+ (int)hold_x, 100+(int)hold_y);
- X ang = ang + step;
- X }
- X SetAPen(rp, (count++ % 8));
- X }
- X
- X Delay(125);
- X
- X /* now the curve has been fully drawn to the screen.
- X * First we'll copy it to the second screen behind this one, then
- X * we'll double buffer it off the screen
- X */
- X
- X /* scroll curve smoothly off the screen using double buffering */
- X for(i=140; i > 4; i-=8) {
- X WaitTOF();
- X BltBitMap(bm1, i,0, bm2, i-4,0, 380,200, 0x0c0,0xff);
- X ScreenToFront(screen2);
- X WaitTOF();
- X BltBitMap(bm2, i-4,0, bm1, i-8,0, 380,200, 0x0c0,0xff);
- X ScreenToFront(screen1);
- X }
- X
- X /* reached left edge, so from here we do things slightly different
- X * than above
- X */
- X for(i=2; i < 70 ; i++) {
- X WaitTOF();
- X BltBitMap(bm1, i,0, bm2, 0,0, 380-i,200, 0x0c0,0xff);
- X ScreenToFront(screen2);
- X WaitTOF();
- X BltBitMap(bm2, i,0, bm1, 0,0, 380-i,200, 0x0c0,0xff);
- X ScreenToFront(screen1);
- X }
- X
- X /* de-allocate everything and exit. Simple eh? ;^) */
- X killscreen(screen1);
- X killscreen(screen2);
- X
- X closelibs();
- X exit(0L);
- X}
- X
- END_OF_FILE
- if test 3150 -ne `wc -c <'demo_src/sin/sin.c'`; then
- echo shar: \"'demo_src/sin/sin.c'\" unpacked with wrong size!
- fi
- # end of 'demo_src/sin/sin.c'
- fi
- if test ! -d 'doc' ; then
- echo shar: Creating directory \"'doc'\"
- mkdir 'doc'
- fi
- if test -f 'doc/closelibs.doc' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'doc/closelibs.doc'\"
- else
- echo shar: Extracting \"'doc/closelibs.doc'\" \(419 characters\)
- sed "s/^X//" >'doc/closelibs.doc' <<'END_OF_FILE'
- XFUNCTION closelibs() - close any previously opened libraries
- X
- X closelibs()
- X
- XThis function will close any previously opened libraries. If you can
- Xopen it with openlibs() - this function will close it. Doesn't take
- Xany parameters and all it does is call CloseLibrary() for each currently
- Xopened library.
- X
- X
- XTODO : Need to support the other libraries that I eventually support in
- X openlibs().
- X
- X
- XBUGS : None.
- X
- X
- END_OF_FILE
- if test 419 -ne `wc -c <'doc/closelibs.doc'`; then
- echo shar: \"'doc/closelibs.doc'\" unpacked with wrong size!
- fi
- # end of 'doc/closelibs.doc'
- fi
- if test -f 'doc/create_boolgadget.doc' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'doc/create_boolgadget.doc'\"
- else
- echo shar: Extracting \"'doc/create_boolgadget.doc'\" \(2082 characters\)
- sed "s/^X//" >'doc/create_boolgadget.doc' <<'END_OF_FILE'
- XFUNCTION create_boolgadget() - create a fully spec'ed Boolean gadget
- X
- Xstruct Gadget *create_boolgadget(l_edge, t_edge, flags, activation, text, id)
- X SHORT l_edge, t_edge;
- X USHORT flags, activation;
- X UBYTE *text;
- X USHORT id;
- X
- X This function gives you total control for easily creating boxed boolean
- Xgadgets of all types. You specify exactly the flags and activation types
- Xof the gadget and where the top corner should be, and the rest is taken
- Xcare of. The text you specify is centered in the gadget and the gadget has
- Xthe ID you give.
- X
- X You can specify any types of flags you would like, however not much
- Xerror checking is done on these values. Be careful for silly combinations.
- XYou should also remember that you MUST specify either GADGHBOX or GADGHCOMP
- Xfor the flags argument. It is also useful to at minimum specify RELVERIFY
- Xfor the Activation argument. Finally, you should make sure that your
- Xwindow is listening for Gadget messages (either gadget UP or gadget DOWN).
- X
- X This function will NOT add the gadget to your window. This is
- Xsomething you must do afterwards else you will never see your gadget. The
- Xonly thing this function does is to allocate space and return a pointer to
- Xthe properly filled out structure.
- X
- X The following example will create a boolean gadget at 100,25
- Xwhich is highlighted by a box. The text inside the gadget will be
- X"Don't have a cow dude" and the gadget will have an id of 42.
- X
- X struct Window *win; /* assume opened earlier */
- X struct Gadget *gadg;
- X char *string = "Don't have a cow dude";
- X
- X gadg = create_boolgadget(100,25, GADGHBOX, RELVERIFY, string, 42);
- X if (gadg == NULL)
- X error_no_gadg();
- X
- X /* add it to the window and make it appear */
- X AddGadget(gadg, win, NULL);
- X RefreshGList(gadg, win, NULL, 1);
- X
- X
- XTODO : should provide a way for specifying custom imagery. Most likely
- X that will have to be a seperate call.
- X
- XBUGS : maybe, maybe not (preferably the latter).
- X
- XSEE ALSO : makeboolgadget(), killgadget(), getyn(), getstring(),
- X makewindow()
- X
- X
- END_OF_FILE
- if test 2082 -ne `wc -c <'doc/create_boolgadget.doc'`; then
- echo shar: \"'doc/create_boolgadget.doc'\" unpacked with wrong size!
- fi
- # end of 'doc/create_boolgadget.doc'
- fi
- if test -f 'doc/createwindow.doc' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'doc/createwindow.doc'\"
- else
- echo shar: Extracting \"'doc/createwindow.doc'\" \(2118 characters\)
- sed "s/^X//" >'doc/createwindow.doc' <<'END_OF_FILE'
- XFUNCTION createwindow() - create a fully spec'ed Intuition window
- X
- X struct Window *createwindow(screen, flags, idcmp,
- X leftedge, topedge,
- X width, height)
- X struct Screen *screen;
- X ULONG flags, idcmp;
- X int leftedge, topedge, width, height;
- X
- X This function allows you the most flexibility over specifying a window.
- XEssentially, you can create any type of window you would like with this
- Xcall. Flags and idcmp are exactly as you would specify in a NewWindow
- Xstructure, and are passed directly through. If you specify screen as
- Xnon-NULL, the window will be opened on that screen.
- X
- X Some error checking of your position variables is done, however it is
- Xstill possible to screw yourself if you get too outlandish (like negative
- Xleftedge, etc). Keep this in mind if passing negative numbers could be a
- Xproblem.
- X
- X A pointer to the freshly created window will be returned, or NULL if
- Xthe window could not be opened. You should definitely error check the
- Xreturn from this function.
- X
- X To open a simple window with only a title bar, disk inserted messages
- Xfrom Intuition, at 100,50 and 200 pixels wide by 75 pixels high, you would
- Xdo the following :
- X
- X struct Window *win;
- X
- X win = createwindow(NULL, WINDOWDRAG, DISKINSERTED, 100,50, 200, 75)
- X if (win == NULL)
- X no_window();
- X
- X The function call above simply asks for a window with a title bar, and
- Xan Intuition port to which DISKINSERTED messages will arrive. The window
- Xwould have a top corner at 100,50, and would be 200 pixels wide and 75
- Xpixels high.
- X
- X Of course you can specify any combination of flags and idcmp messages.
- XYou must make sure they make sense to your application however. For
- Xexample it would not make much sense to ask for CLOSEWINDOW Intuition
- Xmessages if you have not asked for a Close Gadget in the flags variable.
- X
- X
- XTODO : probably should error check the flags/idcmp arguments and modify the
- X flags argument to agree with the idcmp arg. This would be to take
- X care of problems such as in the last paragraph.
- X
- XBUGS : bunny?
- X
- XSEE ALSO : makewindow(), makescreen()
- X
- X
- X
- X
- END_OF_FILE
- if test 2118 -ne `wc -c <'doc/createwindow.doc'`; then
- echo shar: \"'doc/createwindow.doc'\" unpacked with wrong size!
- fi
- # end of 'doc/createwindow.doc'
- fi
- if test -f 'doc/defines.doc' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'doc/defines.doc'\"
- else
- echo shar: Extracting \"'doc/defines.doc'\" \(3968 characters\)
- sed "s/^X//" >'doc/defines.doc' <<'END_OF_FILE'
- XMACROS this file describes several macros that have been defined
- X in ezlib.h
- X
- X The file ezlib.h contains a few macros to 1) in general make life a
- Xlittle easier, and 2) to facilitate working with ez.lib.
- X
- X As mentioned in openlibs.doc, there are several numbers defined to
- Xspecify which libraries to open in a call to openlibs(). They are:
- X
- X #define GFX 0x001
- X #define INTUI 0x002
- X #define INTUITION 0x002
- X #define ARP 0x004
- X #define DFONT 0x008
- X #define DISKFONT 0x008
- X #define TRANSLATOR 0x010
- X #define REXX 0x100
- X
- X As you can see, they are readily or'ed together to open several
- X libraries at once. Not much else to say here.
- X
- X----------------------------------------------------------------------
- X
- X Next there is the MSG() macro taken from an old Transactor. This is a
- Xsimple macro to put out a string onto whatever output stream may be
- Xattatched to your program (i.e. whether from WorkBench or the CLI). It is
- Xdefined as follows :
- X
- X #define MSG(a) (Write(Output(), a, strlen(a)))
- X
- X Again, it will simply dump out a string onto your output stream. Note
- Xthat it is NOT the same as a printf() call and does NOT take formatting
- Xarguments as does printf().
- X
- X----------------------------------------------------------------------
- X
- X
- X Following are macros to set the colors on a custom screen. Several
- X"colors" have also been defined. The macro is setcolor() and is called
- Xlike this :
- X
- X setcolor(screen, num, color)
- X
- XScreen is the pointer to your custom screen which you opened earlier with
- Xmakescreen() or similar.
- X
- XNum is the number of the color register you wish to set. The highest color
- Xregister which you can set is dependent on the depth of the depth (in
- Xbitplanes) of your screen. In any case, it will never be more than 32.
- X
- XColor is the actual color you wish to set. It is a number between 0 and
- X4,095. Essentially, only the first twelve (12) bits matter. The color
- Xdefined by your number is as follows: The first 4 bits (0-3) are BLUE.
- XThe next 4 bits (4-7) are GREEN, and the next 4 bits (8-11) are RED. To
- Xdefine a pure blue color, you would specify (in hex) 0x00f. A nice purple
- Xwould be (again in hex) 0xf0f. To save you the hassle of figuring out what
- Xcolor is what, I have defined the following colors in ezlib.h :
- X
- X BLACK WHITE RED GREEN BLUE YELLOW
- X PINK PURPLE GREY0 GREY1 GREY2 GREY3
- X ORANGE INDIGO CYAN GOLD
- X
- X For example to set the background color of your screen to GREEN, all
- Xyou need do (after having opened a screen) is the following:
- X
- X setcolor(screen, 0, GREEN);
- X
- X For the curious, setcolor() calls SetRGB4().
- X
- X----------------------------------------------------------------------
- X
- X
- X The are 5 more #defines. They are :
- X
- X initgfx() - simply a call to openlibs(GFX)
- X closegfx() - simply a call to closelibs (be careful as
- X this will also close everything else)
- X
- X Print(rp, string) - Call this with a RastPort pointer and a
- X a string. That string will be printed
- X starting at the current pen location in
- X that RastPort.
- X
- X Circle(rp, x, y, rad) - Draw a circle at x,y with radius rad in the
- X rastport pointed to by rp.
- X
- X Line(rp, x1, y1, x2, y2) - Draw a line from x1,y1 to x2,y2. Believe it or
- X not, there is no function like this in Gfxlib.
- X You are supposed to Move() then Draw(). This
- X macro takes care of that for you.
- X
- X Remember, the last 3 "functions" are really just #defines, so there is
- Xno overhead in calling them.
- X
- X----------------------------------------------------------------------
- X
- X
- X That about covers the ezlib.h file. I have also defined some
- Xfunctions and their return values, but not having an ANSI compiler I
- Xhaven't prototyped them. This would be a *very* good idea to do (so would
- Xgetting an ANSI compiler ;-).
- X
- X
- XTODO - can't think of anything
- X
- XBUGS - in a #define ? ;-)
- X
- X
- END_OF_FILE
- if test 3968 -ne `wc -c <'doc/defines.doc'`; then
- echo shar: \"'doc/defines.doc'\" unpacked with wrong size!
- fi
- # end of 'doc/defines.doc'
- fi
- if test -f 'doc/free_bitmap.doc' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'doc/free_bitmap.doc'\"
- else
- echo shar: Extracting \"'doc/free_bitmap.doc'\" \(741 characters\)
- sed "s/^X//" >'doc/free_bitmap.doc' <<'END_OF_FILE'
- XFUNCTION free_bitmap() - Free up a previously allocated bitmap struct
- X
- X free_bitmap(bm, width, height)
- X struct BitMap *bm;
- X int width, height;
- X
- X This function will simply free up all the resources taken by the given
- Xbitmap. The BitMap structure itself is freed, and should no longer be used
- Xafter this function.
- X
- X Just make sure to call this function on a previously allocated bitmap,
- Xand not something like your custom screen bitmap. Preferably you would
- Xhave used something like getbitmap() to allocate the bitmap you wish to
- Xfree.
- X
- XTODO : maybe get rid of the width,height arguments? could calculate it
- X internally, but I might be off
- X
- XBUGS : roaches, ants, gnats, etc...
- X
- XSEE ALSO : getbitmap(), makescreen()
- X
- END_OF_FILE
- if test 741 -ne `wc -c <'doc/free_bitmap.doc'`; then
- echo shar: \"'doc/free_bitmap.doc'\" unpacked with wrong size!
- fi
- # end of 'doc/free_bitmap.doc'
- fi
- if test -f 'doc/getbitmap.doc' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'doc/getbitmap.doc'\"
- else
- echo shar: Extracting \"'doc/getbitmap.doc'\" \(1244 characters\)
- sed "s/^X//" >'doc/getbitmap.doc' <<'END_OF_FILE'
- XFUNCTION getbitmap() - allocate and initialize an arbitrary bitmap
- X
- X struct BitMap *getbitmap(depth, width, height)
- X int depth, width, height;
- X
- X This function will return a pointer to a bitmap of your specified
- Xdepth, width, and height. It will return NULL if any of the memory
- Xallocations fail (of course taking care to free any memory it has already
- Xallocated).
- X
- X Note that the depth variable has a maximum value of 8. If you ask for
- Xmore, the call will fail immediately.
- X
- X In this example, we will allocate a secondary 3 bitplane bitmap of
- X100x75 pixels. This could be very useful for calls to BltBitMap() :
- X
- X struct BitMap *bm;
- X
- X bm = getbitmap(3, 100, 75);
- X if (bm == NULL)
- X no_bitmap();
- X
- X /* continue doing stuff ... */
- X
- X /* free up all that allocated memory */
- X free_bitmap(bm, 100, 75);
- X
- X This call is basically useful for allocating backup storage for making
- Xcalls to BltBitMap() (or its cousins). Just remember to check the error
- Xreturn, and other than that you get a fully initialized and allocated
- Xbitmap structure to your specs! ;^)
- X
- XTODO : can't think of much else....
- X
- XBUGS : what's up doc?
- X
- XELMER FUDD : come here you silly wabbit!
- X
- XSEE ALSO : free_bitmap(), makescreen()
- X
- END_OF_FILE
- if test 1244 -ne `wc -c <'doc/getbitmap.doc'`; then
- echo shar: \"'doc/getbitmap.doc'\" unpacked with wrong size!
- fi
- # end of 'doc/getbitmap.doc'
- fi
- if test -f 'doc/getfont.doc' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'doc/getfont.doc'\"
- else
- echo shar: Extracting \"'doc/getfont.doc'\" \(2293 characters\)
- sed "s/^X//" >'doc/getfont.doc' <<'END_OF_FILE'
- XFUNCTION getfont() - open a disk font for use.
- X
- X struct TextFont *getfont(name size)
- X char *name;
- X int size;
- X
- X Getfont() gives you easy access to the disk based fonts of the Amiga.
- XAll you have to do is pass the name (a character string) of the font and
- Xthe size you would like. If opening the font succeeds, you will be able to
- Ximmediately SetFont(rp, text_font) in your current window and use it from
- Xthen on (with the Text() function). This function returns NULL if anything
- Xfails.
- X
- X The name you pass to getfont() can have a ".font" extension or not. If
- Xit doesn't, then it will be appended. Also be aware that if you specify a
- Xfull pathname for name, that font need NOT be in the current FONTS:
- Xdirectory. This is a little known but true fact.
- X
- X Size should simply be the point size of the font you want. For example
- Xif you want Times 17, you would use size == 17.
- X
- X To open a font called "helvetica" in a 23 point size you would do this:
- X
- X struct Window *wind; /* assume we opened it earlier */
- X struct TextFont *tf;
- X
- X /* open the font and error check the result */
- X tf = getfont("helvetica", 23);
- X if (tf == NULL)
- X no_font();
- X
- X SetFont(wind->RPort, tf); /* from now on we can use the font */
- X
- X ..... /* do other stuff */
- X
- X CloseFont(tf); /* do this BEFORE calling killwindow() */
- X
- X
- XNOTE : You should call CloseFont() before calling killwindow(). This will
- X prevent fonts from being kept in memory unnecessarily. It is best
- X if you can call CloseFont() as soon as you are done with the font.
- X This prevents wasting memory.
- X
- X
- X Essentially, there are 3 steps to using a disk font. Open the font
- Xwith getfont(). Then call SetFont() for the window/screen you wish to use
- Xthe font on. Then use the graphics library text routines for whatever you
- Xwant. Finally call CloseFont() when you are done. Nice and easy.
- X
- X
- X
- XTODO : should probably be some sort of resource tracking so that you don't
- X have to call CloseFont().
- X
- X would be nice if there was a single call you could make to open and
- X set the font for a window (and then not have to worry about after
- X that because of the item above).
- X
- X
- XBUGS : ha! c'mon -(;-) (smiley with a mohawk!)
- X
- XSEE ALSO : makewindow(); makescreen();
- X
- X
- END_OF_FILE
- if test 2293 -ne `wc -c <'doc/getfont.doc'`; then
- echo shar: \"'doc/getfont.doc'\" unpacked with wrong size!
- fi
- # end of 'doc/getfont.doc'
- fi
- if test -f 'doc/getstring.doc' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'doc/getstring.doc'\"
- else
- echo shar: Extracting \"'doc/getstring.doc'\" \(2475 characters\)
- sed "s/^X//" >'doc/getstring.doc' <<'END_OF_FILE'
- XFUNCTION getstring() - Get a string from the user, using a window
- X
- X char *getstring(screen, title, def_string)
- X struct Screen *screen;
- X char *title;
- X char *def_string;
- X
- X This function will pop open a window to prompt the user for a string.
- XThe window has o.k. and cancel gadgets, and in addition, a Close gadget.
- XThe string you wish to get should be less than 256 characters (the default
- Xbuffer size).
- X
- X The screen argument is a pointer to a screen on which to open the
- Xnew window. The screen argument can be NULL in which case the window will
- Xsimply appear on the Workbench screen. The title argument will be the
- Xtitle of the new window. The def_string argument is a pointer to the
- Xdefault string that will appear in the string gadget.
- X
- X This function will return NULL if the user clicks the Close Gadget or
- Xclicks the cancel gadget. If they click the "OK" gadget or press return in
- Xthe string gadget, you will get a pointer to a string back. The string is
- Xdynamically allocated and you must free it when you are done with a call to
- XFreeMem() (see below).
- X
- X Here is an example that gets back the users name and prints it in the
- X CLI window. In this example, the window will appear on workbench,
- X have a window title "Please enter your name", and there will be no
- X default string.
- X
- X char *string;
- X
- X string = getstring(NULL, "Please enter your name", NULL);
- X
- X if (string == NULL)
- X printf("User does not have a name.\n");
- X else {
- X printf("Your name is %s.\n", string);
- X
- X /* for this example we are done with the string, so we will free
- X * it now.
- X * !!!!!! ** NOTICE ** !!!!!!
- X * You should be very careful to make sure that you free the
- X * proper amount of memory using the following style call.
- X * The size you MUST free is the length of the string + 1.
- X * This is VERY IMPORTANT as otherwise you mess up memory.
- X */
- X FreeMem(string, strlen(string)+1);
- X } /* ^^^^ The +1 is _very_ important! */
- X
- X
- X Again, if you want this window to appear on a custom screen (opened by
- Xa call to makescreen() or similar) you should pass it the screen pointer
- Xinstead of NULL as the first argument.
- X
- X You should also check to make sure you didn't get back an empty string.
- X
- X
- X
- XTODO : Probably should (again) make this into a higher level routine with
- X lower level support routines. For now this works however.
- X
- XBUGS : None to the best of my knowledge.
- X
- XSEE ALSO : getyn(); makewindow()
- X
- END_OF_FILE
- if test 2475 -ne `wc -c <'doc/getstring.doc'`; then
- echo shar: \"'doc/getstring.doc'\" unpacked with wrong size!
- fi
- # end of 'doc/getstring.doc'
- fi
- if test -f 'doc/getyn.doc' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'doc/getyn.doc'\"
- else
- echo shar: Extracting \"'doc/getyn.doc'\" \(1990 characters\)
- sed "s/^X//" >'doc/getyn.doc' <<'END_OF_FILE'
- XFUNCTION getyn() - get a yes or no answer using a requestor
- X
- X getyn(window, string)
- X struct Window *window;
- X char *string;
- X
- X This function will get a simple yes or no answer from a user. You pass
- Xgetyn() a string which is put into an AutoRequest(). If the user clicks
- Xo.k., TRUE is returned, otherwise FALSE. This function is useful in many
- Xsituations to just let the user know what is going on, and of course for
- Xyes/no questions.
- X
- X If you pass getyn() a NULL window pointer, it will return NULL to you.
- XIf for any reason the AutoRequest() can not be made, this function will
- Xalso return NULL. Therefore you should keep this in mind when you use
- Xgetyn(). Also note that if there isn't enough memory for a full
- XAutoRequest() (similar to the Insert Volume xxx requestors), the getyn()
- Xfunction will degenerate into a display alert (a recoverable guru box!).
- XThis can be scary for novice users, but only happens in *very* low memory
- Xconditions.
- X
- X The string you pass getyn() should fit horizontally on one line across
- Xthe display. If not, the AutoRequest() will not open and you will get
- XNULL back.
- X
- X Here is an example of using getyn() to find out if the user is really a
- Xweenie:
- X
- X struct Window *wind; /* assume it was opened earlier */
- X int value;
- X
- X value = getyn(wind, " Are you a weenie? ");
- X if (value == TRUE)
- X user_is_a_weenie();
- X else
- X user_is_cool();
- X
- X
- X Likewise, if you would just like to inform the user that something has
- Xhappened or is about to happen, you can do the following:
- X
- X struct Window *wind; /* again, assume it was opened earlier */
- X
- X /* doing some processing and something occurs */
- X
- X getyn(wind, " Did you know that XXX just happened? ");
- X
- X /* keep going .... */
- X
- X
- X
- XTODO : would be nice if you could do multi-line requestors using some
- X sort of embedded character to signify a line break.
- X
- XBUGS : None at time of publication.
- X
- XSEE ALSO : getstring(); makewin(); makescreen();
- X
- X
- END_OF_FILE
- if test 1990 -ne `wc -c <'doc/getyn.doc'`; then
- echo shar: \"'doc/getyn.doc'\" unpacked with wrong size!
- fi
- # end of 'doc/getyn.doc'
- fi
- if test -f 'doc/killgadget.doc' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'doc/killgadget.doc'\"
- else
- echo shar: Extracting \"'doc/killgadget.doc'\" \(1305 characters\)
- sed "s/^X//" >'doc/killgadget.doc' <<'END_OF_FILE'
- XFUNCTION killgadget() - Remove and de-allocate a gadget
- X
- X killgadget(win, gadg)
- X struct Window *win;
- X struct Gadget *gadg;
- X
- X This function will remove a gadget from your window and de-allocate all
- Xof its resources. After this call, gadg will be invalid and will no
- Xlonger appear in your window.
- X
- X Unfortunately this call is not orthogonal to the rest of the kill()
- Xfunctions, as it needs to know the window from whence it came (to be able
- Xto make the gadget go away).
- X
- X In case you would want to do this on your own, the memory that is freed
- Xis as follows (in reverse order from how it was allocated) :
- X
- X gadg->GadgetRender->XY : 10 * sizeof(SHORT)
- X gadg->GadgetRender : sizeof(struct Border)
- X gadg->IText : sizeof(struct IntuiText)
- X gadg : sizeof(struct Gadget)
- X
- X
- X You should make sure that any dynamically allocated text that may be in
- Xyour gadget is managed properly (by having a backup pointer or freeing it
- Xbefore this call).
- X
- X After this call, the specified gadget should no longer appear in your
- Xwindow.
- X
- XTODO : maybe not require the window pointer. could stuff the value in the
- X user data field, but then the user can't use that field.
- X
- XBUGS : shouldn't be
- X
- XSEE ALSO : makeboolgadet(), create_boolgadget(), getyn(), getstring()
- X
- X
- END_OF_FILE
- if test 1305 -ne `wc -c <'doc/killgadget.doc'`; then
- echo shar: \"'doc/killgadget.doc'\" unpacked with wrong size!
- fi
- # end of 'doc/killgadget.doc'
- fi
- if test -f 'doc/killscreen.doc' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'doc/killscreen.doc'\"
- else
- echo shar: Extracting \"'doc/killscreen.doc'\" \(1213 characters\)
- sed "s/^X//" >'doc/killscreen.doc' <<'END_OF_FILE'
- XFUNCTION killscreen() - (safely) Close a previously opened screen
- X
- X killscreen(screen)
- X struct Screen *screen;
- X
- X This function will close the screen you pass it. If the screen has a
- Xdepth of greater than 2 (depth > 2) the bitmap data will be freed also. If
- Xyou have changed the screen->ExtData field from what it originally was
- Xjust after you called makescreen(), you should put it back to the
- Xoriginal value BEFORE you make this call. (The ExtData field points to
- Xthe BitMap structure that was allocated when creating the screen - and
- Xnote: this is not the same BitMap structure that is in your Screen struct).
- X
- X If there are any windows left on the screen, this function will
- Xwait for them to go away before closing. Note that killscreen() will
- Xkeep waiting forever until the windows are gone, so make sure that any
- Xwindows without close gadgets/menus on them are closed before you call
- Xthis. Else you will be in an infinite (but slow) loop. The point
- Xhere is that if you have a borderless backdrop window on a screen, and
- Xyou call killscreen() - you are screwed, glued, and tatooed unless
- Xsomeone else closes that window for you.
- X
- X
- XTODO : nothing
- X
- XBUGS : nope.
- X
- XSEE ALSO : killwindow()
- X
- X
- X
- END_OF_FILE
- if test 1213 -ne `wc -c <'doc/killscreen.doc'`; then
- echo shar: \"'doc/killscreen.doc'\" unpacked with wrong size!
- fi
- # end of 'doc/killscreen.doc'
- fi
- if test -f 'doc/killwindow.doc' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'doc/killwindow.doc'\"
- else
- echo shar: Extracting \"'doc/killwindow.doc'\" \(912 characters\)
- sed "s/^X//" >'doc/killwindow.doc' <<'END_OF_FILE'
- XFUNCTION killwindow() - (safely) Close a previoulsy opened window
- X
- X killwindow(window)
- X struct Window *window;
- X
- X This function will close the window you pass it. If you have menus
- Xattatched to the window, they will be cleared before the window closes.
- XHowever if you have already cleared the menus yourself (with
- XClearMenuStrip() ), then you must NULL out the window->MenuStrip field
- Xbefore you call killwindow().
- X
- X There are no return values from this function.
- X
- X It is safe to pass a NULL pointer to this function (it checks for
- Xthat). This function will also reply to any existing messages that are at
- Xyour window->UserPort (making it safe to call anytime).
- X
- XTODO : Not really much else I can do. Might possibly want to do some sort
- X of resource tracking using the UserData field (for gadgets etc).
- X
- XBUGS : you kidding? ;-)
- X
- XSEE ALSO : makewindow(); killscreen(); makescreen();
- X
- X
- X
- END_OF_FILE
- if test 912 -ne `wc -c <'doc/killwindow.doc'`; then
- echo shar: \"'doc/killwindow.doc'\" unpacked with wrong size!
- fi
- # end of 'doc/killwindow.doc'
- fi
- if test -f 'doc/laced_wb.doc' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'doc/laced_wb.doc'\"
- else
- echo shar: Extracting \"'doc/laced_wb.doc'\" \(335 characters\)
- sed "s/^X//" >'doc/laced_wb.doc' <<'END_OF_FILE'
- XFUNCTION laced_wb() - Return true/false if WB is interlaced or not
- X
- X int laced_wb()
- X
- X This function will return TRUE if the current Workbench screen is
- Xinterlaced, or FALSE if the current Workbench screen is non-interlaced.
- X
- XTODO : what else could there be for this one?
- X
- XBUGS : ha!
- X
- XSEE ALSO : makewindow(), makescreen()
- X
- END_OF_FILE
- if test 335 -ne `wc -c <'doc/laced_wb.doc'`; then
- echo shar: \"'doc/laced_wb.doc'\" unpacked with wrong size!
- fi
- # end of 'doc/laced_wb.doc'
- fi
- if test -f 'doc/makeboolgadget.doc' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'doc/makeboolgadget.doc'\"
- else
- echo shar: Extracting \"'doc/makeboolgadget.doc'\" \(2662 characters\)
- sed "s/^X//" >'doc/makeboolgadget.doc' <<'END_OF_FILE'
- XFUNCTION makeboolgadget() - create an autosizing boolean gadget
- X
- X struct Gadget *makeboolgadget(win, l_edge, t_edge, text, id)
- X struct Window *win;
- X SHORT l_edge, t_edge;
- X UBYTE *text;
- X USHORT id;
- X
- X This function will create a boolean gadget in your window. The gadget
- Xwill have your specified text, and id. The size is calculated
- Xautomatically to nicely fit the given text (although there is a minimum
- Xsize of 30 pixels). The return value is a pointer to the created gadget.
- XYou should keep this pointer so that you can later remove the gadget with a
- Xcall to killgadget().
- X
- X The gadget returned is dynamically allocated, so take care to call
- Xkillgadget() when you are done with the gadget. Note that you should call
- Xkillgadget() before you call killwindow().
- X
- X The created gadget will have the id you specify so that you will be
- Xable to determine from your Intuition messages which gadget was pressed.
- XYou should take care to make sure that you will receive the GADGETUP
- Xmessages in your window. Windows created with makewindow() do not receive
- Xthese types of messages, however, you can use the Intuition function
- XModifyIDCMP() to change this behavior.
- X
- X The gadgets created by this call are simple box affairs with the
- Xhighlight mode set to COMPLEMENT. The text is centered and should be
- Xoffset nicely. The gadgets are not crowded or otherwise unsightly, except
- Xfor being rather plain.
- X
- X To create a boolean gadget with the text "Click Me", you would do the
- Xfollowing (assuming an already opened window) :
- X
- X struct Window *win; /* opened beforehand */
- X struct Gadget *click_me;
- X
- X click_me = makeboolgadget(win, 100, 25, "Click Me", 43);
- X
- X /* do whatever we want (i.e. main loop, etc...) */
- X
- X /* free up gadget resources (i.e. memory) */
- X killgadget(win, click_me);
- X
- X The previous code will create and cause to be displayed an autosized
- Xboolean gadget at 100, 25 which contains the text "Click Me", and has a
- Xgadget ID of 43. makeboolgadget() WILL take care of making sure the
- Xgadget is displayed, so you need not do anything after the return from the
- Xfunction. You should however keep track of the allocated gadgets so that
- Xyou can properly free their allocated memory.
- X
- X For the curious, this function calls the lower level function
- Xcreate_boolgadget() with appropriate values. It then calls AddGList() and
- XRefreshGList() to cause the gadget to display.
- X
- XTODO : Really need to make the gadgets more 3d'ish. They look kinda plain
- X now.
- X
- XBUGS : could be, but none that I've seen (fingers crossed)
- X
- XSEE ALSO : create_boolgadget(), killgadget(), makewindow(), getyn(),
- X getstring()
- X
- END_OF_FILE
- if test 2662 -ne `wc -c <'doc/makeboolgadget.doc'`; then
- echo shar: \"'doc/makeboolgadget.doc'\" unpacked with wrong size!
- fi
- # end of 'doc/makeboolgadget.doc'
- fi
- if test -f 'doc/makescreen.doc' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'doc/makescreen.doc'\"
- else
- echo shar: Extracting \"'doc/makescreen.doc'\" \(2593 characters\)
- sed "s/^X//" >'doc/makescreen.doc' <<'END_OF_FILE'
- XFUNCTION makescreen() - Easily create a custom screen
- X
- X struct Screen *makescreen(modes, depth)
- X int modes;
- X int depth;
- X
- X This function will create a custom screen of the specified modes and
- Xdepth for you. makescreen() will return NULL if something couldn't be
- Xallocated or created. Check the return value to make sure you have a
- Xvalid screen pointer. Valid modes are defined in graphics/view.h. The
- Xmore common ones are :
- X
- X LORES - open a 320x200 screen
- X HIRES - open a hires (640 pixels across) screen
- X LACE - make the screen interlace (400 vertical lines)
- X EXTRA_HALFBRITE - specify extra half bright mode (64 colors)
- X HAM - make a HAM (hold and modify) 4096 color screen.
- X
- X If you specify NULL for modes, you will get a standard 320x200 screen.
- X
- X Some checking is done to make sure that you don't screw yourself.
- XIf graphics.library and intuition.library aren't opened before you call
- Xthis function, they WILL be opened for you.
- X
- X If you specify a depth of greater than 2 (depth > 2), the bitmap data
- Xyou need will be allocated. However, the ExtData field of the screen
- Xstructure will be used to hold some information needed for later when you
- Xcall killscreen(). This is a warning that you should not use the
- Xscreen->ExtData field, or if you do, you should save its value and put it
- Xback BEFORE you call killscreen().
- X
- X Also be advised that some programs illegally modify the
- Xscreen->UserData field of your PRIVATE custom screen. QMouse was caught
- Xblatantly doing this horrendous crime (at least as far as I could tell).
- XThis is definitely a bug in QMouse, but since I really like QMouse, I
- Xchanged Ez.lib to use the screen->ExtData field. BTW, you wanna talk about
- Xa hard to find bug, try tracking that one down!
- X
- X To open a HIRES 3 bitplane screen you would do the following :
- X
- X struct Screen *screen;
- X
- X screen = makescreen(HIRES, 3);
- X if (screen == NULL)
- X no_screen();
- X
- X To open a LORES (320x200) 5 bitplane screen, do this :
- X
- X struct Screen *screen;
- X
- X screen = makescreen(LORES, 5);
- X if (screen == NULL)
- X no_screen();
- X
- X To open a LORES, interlaced, extra half-brite screen of
- X 6 bitplanes, do this :
- X
- X struct Screen *screen;
- X
- X screen = makescreen(LORES|LACE|EXTRA_HALFBRITE, 6);
- X if (screen == NULL)
- X no_screen();
- X
- X
- XTODO : maybe more error checking on the modes field. Everything should be
- X covered however. Probably should #define LORES 0 in lib.h so that
- X the calls to makescreen are more readable.
- X
- XBUGS : None
- X
- XSEE ALSO : killscreen(screen); makewindow();
- X
- X
- X
- X
- END_OF_FILE
- if test 2593 -ne `wc -c <'doc/makescreen.doc'`; then
- echo shar: \"'doc/makescreen.doc'\" unpacked with wrong size!
- fi
- # end of 'doc/makescreen.doc'
- fi
- if test -f 'doc/makewindow.doc' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'doc/makewindow.doc'\"
- else
- echo shar: Extracting \"'doc/makewindow.doc'\" \(1855 characters\)
- sed "s/^X//" >'doc/makewindow.doc' <<'END_OF_FILE'
- XFUNCTION makewindow() - Easily create an Intution window
- X
- X struct Window *makewindow(screen, leftedge, topedge, width, height)
- X struct Screen *screen;
- X int leftedge, topedge;
- X int width, height;
- X
- X
- X This function will open a standard Intuition window for you. You
- Xspecify a screen pointer if you would like this window to appear on a
- Xcustom screen or NULL if you would like it to appear on the workbench. The
- Xleftedge, topedge, width, and height variables specify the new window's
- Xdimensions. They are error checked for sanity.
- X
- X The window that is opened has a Close Gadget, TitleBar, Depth Gadget,
- Xand a Sizing Gadget. The window is also SMART_REFRESH, therefore you
- Xdon't have to worry about refreshing your display. This is a very high
- Xlevel routine, that doesn't give you much flexibility over the appearance
- Xof the window, but quickly and painlessly gets you a window.
- X
- X Since there is a Close Gadget on this window, you will receive
- XIntuition messages (which you can safely ignore if you want). However it
- Xis better if you do check to see if the user has clicked the Close Gadget
- Xin that window. NOTE: the flags which this window is opened with will only
- Xsend you a CLOSEWINDOW Intuition Message. If you wish to receive other
- Xwindow messages (like DISKINSERTED or something), you should use
- XModifyIDCMP() to tell Intuition you want those messages.
- X
- X
- X Final note, if graphics.library and intuition.library haven't been
- Xopened yet, this routine will open them for you.
- X
- X
- X This example opens a 200x100 window at 0, 0 on the workbench screen:
- X
- X struct Window *window;
- X
- X window = makewindow(NULL, 0,0, 200, 100);
- X if (window == NULL)
- X no_window()
- X
- X
- X
- XTODO : none at the moment. Lets hope software rot doesn't set in.
- X
- XBUGS : none that I know of.
- X
- XSEE ALSO : killwindow(); makescreen(); killscreen();
- X
- X
- END_OF_FILE
- if test 1855 -ne `wc -c <'doc/makewindow.doc'`; then
- echo shar: \"'doc/makewindow.doc'\" unpacked with wrong size!
- fi
- # end of 'doc/makewindow.doc'
- fi
- if test -f 'doc/openlibs.doc' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'doc/openlibs.doc'\"
- else
- echo shar: Extracting \"'doc/openlibs.doc'\" \(1890 characters\)
- sed "s/^X//" >'doc/openlibs.doc' <<'END_OF_FILE'
- XFUNCTION openlibs() - Easily open any of several system libraries
- X
- X openlibs( which_ones )
- X int which_ones;
- X
- X This function takes an integer argument which specifies which libraries
- Xyou would like to have opened for your program. The libraries you can open
- Xare:
- X
- X GFX : graphics.library
- X INTUI or INTUITION : intuition.library
- X DFONT or DISKFONT : diskfont.library
- X ARP : arp.library
- X TRANSLATOR : translator.library
- X REXX : rexxsyslib.library
- X
- X
- XThese values are simply numeric #define's, which can be or'ed together.
- X
- X
- XTo open the graphics.library, you would simply do the following:
- X
- X success = openlibs(GFX);
- X if (success == NULL)
- X deal_with_failure();
- X
- XYou can open multiple libraries with a single call by doing the following:
- X
- X success = openlibs(GFX | ARP | INTUITION | DISKFONT);
- X if (success == NULL)
- X deal_with_failure();
- X
- X The above opens the graphics.library, arp.library, intuition.library,
- Xand diskfont.library all in a single call.
- X
- X If any of the libraries fail to open, openlibs() will print an error
- Xmessage to your output stream saying which library didn't open and it
- Xwill return NULL.
- X
- X openlibs() will close any libraries it opened if a succesive
- XOpenLibrary() call fails. Therefore, you don't have to worry about opened
- Xlibraries sitting around and never being closed. This is to say that if
- Xyou ask for GFX | INTUI | ARP, and graphics.library and intuition.library
- Xopen, but arp.library doesn't, graphics and intuition will be closed down
- Xfor you and NULL returned.
- X
- X
- X
- XTODO : Shouldn't be much else. Maybe a way to add more libraries that
- X can be opened without having to recompile. Possibly a name/variable
- X combo....
- X
- XBUGS : can only support 32 different libraries to be opened. That's not
- X too much of a restriction, but it still is one.
- X
- X
- END_OF_FILE
- if test 1890 -ne `wc -c <'doc/openlibs.doc'`; then
- echo shar: \"'doc/openlibs.doc'\" unpacked with wrong size!
- fi
- # end of 'doc/openlibs.doc'
- fi
- if test -f 'ezlib.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'ezlib.h'\"
- else
- echo shar: Extracting \"'ezlib.h'\" \(1698 characters\)
- sed "s/^X//" >'ezlib.h' <<'END_OF_FILE'
- X/* Header file for use with ez.lib */
- X
- X#define GFX 0x001
- X#define INTUI 0x002
- X#define INTUITION 0x002
- X#define ARP 0x004
- X#define DFONT 0x008
- X#define DISKFONT 0x008
- X#define TRANSLATOR 0x010
- X#define ICONBASE 0x080
- X#define REXX 0x100
- X
- X#define MSG(a) (Write(Output(), a, strlen(a)))
- X
- Xstruct Screen *makescreen();
- Xstruct Window *makewindow();
- Xstruct Window *createwindow();
- Xstruct Gadget *makeboolgadget();
- Xstruct Gadget *create_boolgadget();
- Xstruct BitMap *getbitmap();
- Xstruct TextFont *getfont();
- Xchar *getstring();
- X
- X/* these functions (and closelibs()) should properly be void, however
- X * manx 3.6a seems to think I'm redeclaring the function when a function
- X * is defined here as void. As int it works fine....
- X */
- Xint killscreen();
- Xint killwindow();
- Xint free_bitmap();
- Xint getyn();
- Xint openlibs();
- Xint closelibs();
- X
- X#define setcolor(screen, num, color) (SetRGB4(&screen->ViewPort, num, (0x0f00&color)>>8, (0x00f0&color)>>4, (0x000f&color) ))
- X#define BLACK 0x0000
- X#define WHITE 0x0fff
- X#define RED 0x0f00
- X#define GREEN 0x00f0
- X#define BLUE 0x000f
- X#define YELLOW 0x0ff0
- X#define CYAN 0x00ff
- X#define PINK 0x0f09
- X#define PURPLE 0x0f0f
- X#define GREY0 0x0ccc
- X#define GREY 0x0aaa
- X#define GREY1 0x0888
- X#define GREY2 0x0666
- X#define GREY3 0x0444
- X#define GOLD 0x0ea1
- X#define ORANGE 0x0f70
- X#define INDIGO 0x070e
- X
- X#define initgfx() (openlibs(GFX))
- X#define closegfx() (closelibs())
- X
- X#define Print(rp, b) (Text(rp, b, strlen(b)))
- X#define Line(rp, a, b, c, d) { Move(rp, a, b); Draw(rp, c, d); }
- X#define Circle(rp, x, y, rad) (DrawEllipse(rp, x, y, rad, rad))
- X
- X/* just a quickie to make calls to makescreen() a little more clear */
- X#define LORES 0x0000
- X
- END_OF_FILE
- if test 1698 -ne `wc -c <'ezlib.h'`; then
- echo shar: \"'ezlib.h'\" unpacked with wrong size!
- fi
- # end of 'ezlib.h'
- fi
- if test ! -d 'src' ; then
- echo shar: Creating directory \"'src'\"
- mkdir 'src'
- fi
- if test -f 'src/ezlib.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'src/ezlib.h'\"
- else
- echo shar: Extracting \"'src/ezlib.h'\" \(1659 characters\)
- sed "s/^X//" >'src/ezlib.h' <<'END_OF_FILE'
- X#define GFX 0x001
- X#define INTUI 0x002
- X#define INTUITION 0x002
- X#define ARP 0x004
- X#define DFONT 0x008
- X#define DISKFONT 0x008
- X#define TRANSLATOR 0x010
- X#define ICONBASE 0x080
- X#define REXX 0x100
- X
- X#define MSG(a) (Write(Output(), a, strlen(a)))
- X
- Xstruct Screen *makescreen();
- Xstruct Window *makewindow();
- Xstruct Window *createwindow();
- Xstruct Gadget *makeboolgadget();
- Xstruct Gadget *create_boolgadget();
- Xstruct BitMap *getbitmap();
- Xstruct TextFont *getfont();
- Xchar *getstring();
- X
- X/* these functions (and closelibs()) should properly be void, however
- X * manx 3.6a seems to think I'm redeclaring the function when a function
- X * is defined here as void. As int it works fine....
- X */
- Xint killscreen();
- Xint killwindow();
- Xint free_bitmap();
- Xint getyn();
- Xint openlibs();
- Xint closelibs();
- X
- X#define setcolor(screen, num, color) (SetRGB4(&screen->ViewPort, num, (0x0f00&color)>>8, (0x00f0&color)>>4, (0x000f&color) ))
- X#define BLACK 0x0000
- X#define WHITE 0x0fff
- X#define RED 0x0f00
- X#define GREEN 0x00f0
- X#define BLUE 0x000f
- X#define YELLOW 0x0ff0
- X#define CYAN 0x00ff
- X#define PINK 0x0f09
- X#define PURPLE 0x0f0f
- X#define GREY0 0x0ccc
- X#define GREY 0x0aaa
- X#define GREY1 0x0888
- X#define GREY2 0x0666
- X#define GREY3 0x0444
- X#define GOLD 0x0ea1
- X#define ORANGE 0x0f70
- X#define INDIGO 0x070e
- X
- X#define initgfx() (openlibs(GFX))
- X#define closegfx() (closelibs())
- X
- X#define Print(rp, b) (Text(rp, b, strlen(b)))
- X#define Line(rp, a, b, c, d) { Move(rp, a, b); Draw(rp, c, d); }
- X#define Circle(rp, x, y, rad) (DrawEllipse(rp, x, y, rad, rad))
- X
- X/* just a quickie to make calls to makescreen() a little more clear */
- X#define LORES 0x0000
- X
- END_OF_FILE
- if test 1659 -ne `wc -c <'src/ezlib.h'`; then
- echo shar: \"'src/ezlib.h'\" unpacked with wrong size!
- fi
- # end of 'src/ezlib.h'
- fi
- if test -f 'src/gadg.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'src/gadg.c'\"
- else
- echo shar: Extracting \"'src/gadg.c'\" \(989 characters\)
- sed "s/^X//" >'src/gadg.c' <<'END_OF_FILE'
- X#include "ezlib.h"
- X
- Xmain()
- X{
- X struct Window *win;
- X struct Gadget *test, *test2;
- X struct IntuiMessage *msg, *GetMsg();
- X int id;
- X
- X win = makewindow(NULL, 0, 0, 300, 100);
- X if (win == NULL)
- X exit(10);
- X
- X test = makeboolgadget(win, 100, 25, "Hey there!", 43);
- X test2 = create_boolgadget(100, 50, GADGHBOX, RELVERIFY, "X", 44);
- X AddGadget(win, test2, (USHORT)~0);
- X RefreshGadgets(test2, win, NULL);
- X
- X ModifyIDCMP(win, CLOSEWINDOW|GADGETUP);
- X
- X while(1) {
- X WaitPort(win->UserPort);
- X msg = GetMsg(win->UserPort);
- X
- X switch(msg->Class){
- X case GADGETUP : id = ((struct Gadget*)msg->IAddress)->GadgetID;
- X if (id == 43){
- X Move(win->RPort, 50, 50);
- X Print(win->RPort, "Got a click!");
- X }
- X else if (id == 44) {
- X Move(win->RPort, 80, 20);
- X Print(win->RPort, "Hehehehehehee");
- X }
- X
- X break;
- X
- X case CLOSEWINDOW : killgadget(win, test);
- X killgadget(win, test2);
- X killwindow(win);
- X exit(0);
- X
- X default : break;
- X }
- X ReplyMsg(msg);
- X }
- X}
- X
- END_OF_FILE
- if test 989 -ne `wc -c <'src/gadg.c'`; then
- echo shar: \"'src/gadg.c'\" unpacked with wrong size!
- fi
- # end of 'src/gadg.c'
- fi
- if test -f 'src/gadget.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'src/gadget.c'\"
- else
- echo shar: Extracting \"'src/gadget.c'\" \(3247 characters\)
- sed "s/^X//" >'src/gadget.c' <<'END_OF_FILE'
- X#include "ezlib.h"
- X
- Xextern struct GfxBase *GfxBase;
- Xvoid *AllocMem();
- X
- X/* These functions deal with gadgets and adding them to your window */
- X
- Xstruct Gadget *create_boolgadget(l_edge, t_edge, flags, activation, text, id)
- X SHORT l_edge, t_edge;
- X USHORT flags, activation;
- X UBYTE *text;
- X USHORT id;
- X{
- X struct Gadget *gadg = NULL;
- X struct IntuiText *i_text = NULL;
- X struct Border *bord = NULL;
- X int i,j;
- X
- X if ( (flags & GADGHIMAGE) != NULL)
- X return NULL;
- X
- X if ( (flags & GADGHBOX) == NULL && (flags & GADGHCOMP) == NULL)
- X flags |= GADGHCOMP;
- X
- X /* get everything allocated first, and fail if any of this does */
- X gadg = (struct Gadget *) AllocMem(sizeof(struct Gadget), MEMF_CLEAR);
- X i_text = (struct IntuiText*) AllocMem(sizeof(struct IntuiText), MEMF_CLEAR);
- X bord = (struct Border *) AllocMem(sizeof(struct Border), MEMF_CLEAR);
- X if (bord)
- X bord->XY = (SHORT *)AllocMem(10 * sizeof(SHORT), 0L);
- X
- X if (gadg == NULL || i_text == NULL || bord == NULL || bord->XY == NULL){
- X if (gadg)
- X FreeMem(gadg, sizeof(struct Gadget));
- X if (i_text)
- X FreeMem(i_text, sizeof(struct IntuiText));
- X if (bord) {
- X if (bord->XY)
- X FreeMem(bord->XY, 10*sizeof(SHORT));
- X FreeMem(bord, sizeof(struct Border));
- X }
- X return NULL;
- X }
- X
- X /* do some generic setup stuff */
- X gadg->LeftEdge = l_edge; gadg->TopEdge = t_edge;
- X gadg->Flags = flags; gadg->Activation = activation;
- X gadg->GadgetID = id; gadg->GadgetType = BOOLGADGET;
- X gadg->GadgetText = i_text; gadg->GadgetRender = (APTR)bord;
- X
- X /* fill in the Itext struct */
- X i_text->FrontPen = 2; i_text->DrawMode = JAM1;
- X i_text->LeftEdge = 10; i_text->TopEdge = 3;
- X i_text->IText = text;
- X
- X /* calculate where the box should be and fill in the border struct */
- X bord->LeftEdge = -1; bord->TopEdge = -1;
- X bord->FrontPen = 1; bord->BackPen = 0;
- X bord->DrawMode = JAM1; bord->Count = 5;
- X
- X /* here we calculate where everything should go... */
- X i = IntuiTextLength(i_text) + 22;
- X if (i < 30)
- X i = 30;
- X j = GfxBase->DefaultFont->tf_YSize + 6;
- X
- X bord->XY[0] = 0; bord->XY[1] = 0;
- X bord->XY[2] = i; bord->XY[3] = 0;
- X bord->XY[4] = i; bord->XY[5] = j;
- X bord->XY[6] = 0; bord->XY[7] = j;
- X bord->XY[8] = 0; bord->XY[9] = 0;
- X gadg->Width = i - 1; gadg->Height = j - 1;
- X
- X return gadg;
- X}
- X
- X
- Xstruct Gadget *makeboolgadget(window, l_edge, t_edge, text, id)
- X struct Window *window;
- X SHORT l_edge, t_edge;
- X UBYTE *text;
- X USHORT id;
- X{
- X USHORT flags, activation;
- X struct Gadget *gadg;
- X
- X flags = GADGHCOMP;
- X activation = RELVERIFY;
- X
- X gadg = create_boolgadget(l_edge, t_edge, flags, activation, text, id);
- X if (gadg == NULL)
- X return NULL;
- X
- X AddGadget(window, gadg, (USHORT)~0);
- X RefreshGList(gadg, window, NULL, 1);
- X
- X return gadg;
- X}
- X
- X
- X/* this routine will free up the gadget for you */
- X
- Xkillgadget(win, gadg)
- X struct Window *win;
- X struct Gadget *gadg;
- X{
- X int i;
- X
- X RemoveGadget(win, gadg);
- X RefreshGadgets( win->FirstGadget, win, NULL);
- X
- X FreeMem(((struct Border *)gadg->GadgetRender)->XY, 10*sizeof(SHORT));
- X FreeMem(gadg->GadgetRender, sizeof(struct Border));
- X FreeMem(gadg->GadgetText, sizeof(struct IntuiText));
- X FreeMem(gadg, sizeof(struct Gadget));
- X}
- X
- END_OF_FILE
- if test 3247 -ne `wc -c <'src/gadget.c'`; then
- echo shar: \"'src/gadget.c'\" unpacked with wrong size!
- fi
- # end of 'src/gadget.c'
- fi
- if test -f 'src/getfont.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'src/getfont.c'\"
- else
- echo shar: Extracting \"'src/getfont.c'\" \(1456 characters\)
- sed "s/^X//" >'src/getfont.c' <<'END_OF_FILE'
- X/* This file contains a routine to open a disk based font. It returns
- X * a pointer to a TextFont structure, which if isn't NULL can be immediatly
- X * SetFont()'ed into your rastport.
- X *
- X * It tries to be smart about font names taking care if you didn't append
- X * a ".font" to the font name.
- X */
- X
- X#include "ezlib.h"
- X
- Xextern struct Library *DiskfontBase;
- X
- Xvoid *AllocMem();
- X
- Xstruct TextFont *getfont( name, size )
- X char *name;
- X int size;
- X{
- X struct Library *OpenLibrary();
- X struct TextFont *OpenDiskFont();
- X struct TextFont *txfont;
- X struct TextAttr txattr;
- X LONG len;
- X char *fontname, *test, *ext = ".font", *rindex();
- X UBYTE pre_opened=FALSE;
- X
- X if (DiskfontBase < 100)
- X DiskfontBase = (struct Library *)OpenLibrary("diskfont.library",0L);
- X else
- X pre_opened = TRUE;
- X
- X if (DiskfontBase == NULL) /* just a quickie failsafe.... */
- X return NULL;
- X
- X len = strlen(name) + 6;
- X fontname = (char *)AllocMem(len, 0L);
- X if (fontname == NULL)
- X return NULL;
- X
- X strcpy(fontname, name);
- X test = rindex(fontname, '.');
- X /* if true, then they are not equal */
- X if (test == NULL || strcmp(test, ext))
- X strcat(fontname, ext);
- X
- X txattr.ta_Name = (STRPTR)fontname;
- X txattr.ta_YSize = (UWORD)size;
- X txattr.ta_Style = FS_NORMAL;
- X txattr.ta_Flags = FPF_DISKFONT;
- X
- X txfont = OpenDiskFont(&txattr);
- X
- X FreeMem(fontname, len);
- X if (pre_opened == FALSE) {
- X CloseLibrary(DiskfontBase);
- X DiskfontBase = NULL;
- X }
- X return txfont;
- X}
- X
- END_OF_FILE
- if test 1456 -ne `wc -c <'src/getfont.c'`; then
- echo shar: \"'src/getfont.c'\" unpacked with wrong size!
- fi
- # end of 'src/getfont.c'
- fi
- if test -f 'src/getyn.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'src/getyn.c'\"
- else
- echo shar: Extracting \"'src/getyn.c'\" \(1418 characters\)
- sed "s/^X//" >'src/getyn.c' <<'END_OF_FILE'
- X/* This function will get a yes or no answer from a users. It tries
- X * to be smart about how it opens the autorequest().
- X *
- X * Also you should know that this some of this code came from the DME
- X * source code of the same function. However I have changed it a fair
- X * amount....
- X */
- X
- X#include "ezlib.h"
- X
- Xvoid *AllocMem();
- X
- Xgetyn(win, text)
- Xstruct Window *win;
- Xchar *text;
- X{
- X int result, width;
- X struct IntuiText *body, *pos, *neg;
- X
- X if (win <= 100) /* quick sanity check */
- X return NULL;
- X
- X /* this is a sneaky way to only have to do a single AllocMem instead
- X * of 3 seperate ones (each with error checking).
- X */
- X body = (struct IntuiText *)AllocMem( (3*sizeof(struct IntuiText)), MEMF_CLEAR);
- X if (body == NULL)
- X return NULL;
- X
- X pos = &body[1]; neg = &body[2];
- X
- X body->BackPen = pos->BackPen = neg->BackPen = 1;
- X body->DrawMode = pos->DrawMode = neg->DrawMode = AUTODRAWMODE;
- X body->LeftEdge = 10;
- X body->TopEdge = 12;
- X body->IText = (UBYTE *)text;
- X pos->LeftEdge = pos->TopEdge = AUTOTOPEDGE;
- X pos->IText = (UBYTE *)" OK ";
- X neg->LeftEdge = neg->TopEdge = AUTOTOPEDGE;
- X neg->IText = (UBYTE *)" CANCEL";
- X
- X width = IntuiTextLength(body) + 50;
- X if (width < 150)
- X width = 225;
- X result = AutoRequest(win, body, pos, neg, 0, 0, width, 58);
- X FreeMem(body, (3*sizeof(struct IntuiText)));
- X
- X return(result);
- X}
- X
- END_OF_FILE
- if test 1418 -ne `wc -c <'src/getyn.c'`; then
- echo shar: \"'src/getyn.c'\" unpacked with wrong size!
- fi
- # end of 'src/getyn.c'
- fi
- if test ! -d 'src/include' ; then
- echo shar: Creating directory \"'src/include'\"
- mkdir 'src/include'
- fi
- if test -f 'src/include/includes.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'src/include/includes.h'\"
- else
- echo shar: Extracting \"'src/include/includes.h'\" \(629 characters\)
- sed "s/^X//" >'src/include/includes.h' <<'END_OF_FILE'
- X#include <ctype.h>
- X#include <exec/exec.h>
- X#include <libraries/dos.h>
- X#include <libraries/dosextens.h>
- X/**************** NOT NEEDED #include <libraries/arpbase.h> *************/
- X#include <graphics/rastport.h>
- X#include <graphics/text.h>
- X#include <graphics/view.h>
- X#include <graphics/gfx.h>
- X#include <graphics/gfxbase.h>
- X#include <graphics/gfxmacros.h>
- X#include <intuition/intuition.h>
- X#include <intuition/intuitionbase.h>
- X#include <intuition/preferences.h>
- X#include <intuition/screens.h>
- X/***************** NOT NEEDED #include <arpfunctions.h>****************/
- X#include <workbench/workbench.h>
- X#include <workbench/startup.h>
- X
- X
- END_OF_FILE
- if test 629 -ne `wc -c <'src/include/includes.h'`; then
- echo shar: \"'src/include/includes.h'\" unpacked with wrong size!
- fi
- # end of 'src/include/includes.h'
- fi
- if test -f 'src/makefile' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'src/makefile'\"
- else
- echo shar: Extracting \"'src/makefile'\" \(1411 characters\)
- sed "s/^X//" >'src/makefile' <<'END_OF_FILE'
- X# this is a somewhat stupid makefile. I still haven't learned the
- X# subtleties of the .c.o rules... sigh
- X#
- X# This will compile and make the library. I make use of a pre-compiled
- X# header file as it makes compile times *much* faster. Everything should
- X# work as is if you have to rebuild the library (at least I hope so).
- X#
- X# Oh BTW, the demo that is in the directory above this one is created in
- X# this makefile. This is to test out the library, and if you make changes
- X# you should make sure that the demo still works
- X#
- X
- X# header.h is actually the precompiled header file
- XCFLAGS = +L +Iinclude/header.h
- X
- XOBJS= getstring.o getfont.o getyn.o gadget.o window.o screen.o openlibs.o
- X
- Xall : demo ez.lib include/header.h
- X
- Xinclude/header.h : include/includes.h
- X cc +L +Hinclude/header.h includes.h
- X
- Xdemo : ez.lib demo.o
- X ln -o demo demo.o ez.lib -lc
- X
- Xdemo.o : demo.c
- X cc $(CFLAGS) demo.c
- X
- Xez.lib : $(OBJS)
- X lb ez $(OBJS)
- X
- Xopenlibs.o : openlibs.c ezlib.h
- X cc $(CFLAGS) openlibs.c
- X
- Xscreen.o : screen.c ezlib.h
- X cc $(CFLAGS) screen.c
- X
- Xwindow.o : window.c ezlib.h
- X cc $(CFLAGS) window.c
- X
- Xgadget.o : gadget.c ezlib.h
- X cc $(CFLAGS) gadget.c
- X
- Xgetyn.o : getyn.c ezlib.h
- X cc $(CFLAGS) getyn.c
- X
- Xgetfilename.o : getfilename.c ezlib.h
- X cc $(CFLAGS) getfilename.c
- X
- Xgetfont.o : getfont.c ezlib.h
- X cc $(CFLAGS) getfont.c
- X
- Xgetstring.o : getstring.c ezlib.h
- X cc $(CFLAGS) getstring.c
- X
- END_OF_FILE
- if test 1411 -ne `wc -c <'src/makefile'`; then
- echo shar: \"'src/makefile'\" unpacked with wrong size!
- fi
- # end of 'src/makefile'
- fi
- if test -f 'src/openlibs.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'src/openlibs.c'\"
- else
- echo shar: Extracting \"'src/openlibs.c'\" \(2268 characters\)
- sed "s/^X//" >'src/openlibs.c' <<'END_OF_FILE'
- X/* This file contains the routines for opening and closing libraries.
- X * Notice that all the library bases are defined here. You can access
- X * them in your code if you wish, but they are defined here.
- X *
- X * Oh, it *is* important that they be initialized to zero.
- X */
- X
- X#include "ezlib.h"
- X
- Xstruct GfxBase *GfxBase = NULL;
- Xstruct IntuitionBase *IntuitionBase = NULL;
- Xstruct Library *DiskfontBase = NULL;
- Xstruct ArpBase *ArpBase = NULL;
- Xstruct Library *TranslatorBase = NULL;
- Xstruct RxsLib *RexxSysBase = NULL;
- Xvoid *OpenLibrary();
- X
- Xopenlibs( which_ones )
- X register int which_ones;
- X{
- X register int errs = NULL;
- X
- X if (which_ones & GFX)
- X if ( (GfxBase = (struct GfxBase *)OpenLibrary("graphics.library", 0L)) == NULL)
- X { MSG("No Graphics.library.\n"); errs = 1; }
- X
- X if (which_ones & INTUI)
- X if ( (IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library", 0L)) == NULL)
- X { MSG("No Intuition.library.\n"); errs = 1; }
- X
- X if (which_ones & ARP)
- X if ( (ArpBase = (struct ArpBase *)OpenLibrary("arp.library", 34)) == NULL)
- X { MSG("No Arp.library in your LIBS directory.\n");errs = 1; }
- X
- X if (which_ones & DISKFONT)
- X if ( (DiskfontBase = (struct Library *)OpenLibrary("diskfont.library", 0L)) == NULL)
- X { MSG("No Diskfont.library in your LIBS: directory.\n"); errs = 1; }
- X
- X if (which_ones & TRANSLATOR)
- X if ( (TranslatorBase = (struct Library *)OpenLibrary("translator.library", 0L)) == NULL)
- X { MSG("No Translator.library in your LIBS: directory.\n"); errs = 1; }
- X
- X if (which_ones & REXX)
- X if ( (RexxSysBase = (struct RxsLib *)OpenLibrary("rexxsyslib.library", 0L)) == NULL)
- X { MSG("No rexxsyslib.library in your LIBS: directory.\n"); errs = 1; }
- X
- X if ( errs )
- X { closelibs(); return NULL; }
- X
- X return 1;
- X}
- X
- Xcloselibs()
- X{
- X if (DiskfontBase > 100)
- X { CloseLibrary(DiskfontBase); DiskfontBase = NULL; }
- X
- X if (ArpBase > 100)
- X { CloseLibrary(ArpBase); ArpBase = NULL; }
- X
- X if (IntuitionBase > 100)
- X { CloseLibrary(IntuitionBase); IntuitionBase = NULL; }
- X
- X if (GfxBase > 100)
- X { CloseLibrary(GfxBase); GfxBase = NULL; }
- X
- X if (TranslatorBase > 100)
- X { CloseLibrary(TranslatorBase); TranslatorBase = NULL; }
- X
- X if (RexxSysBase > 100)
- X { CloseLibrary(RexxSysBase); RexxSysBase = NULL; }
- X}
- X
- END_OF_FILE
- if test 2268 -ne `wc -c <'src/openlibs.c'`; then
- echo shar: \"'src/openlibs.c'\" unpacked with wrong size!
- fi
- # end of 'src/openlibs.c'
- fi
- if test -f 'src/window.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'src/window.c'\"
- else
- echo shar: Extracting \"'src/window.c'\" \(3360 characters\)
- sed "s/^X//" >'src/window.c' <<'END_OF_FILE'
- X#include "ezlib.h"
- X
- Xextern struct GfxBase *GfxBase;
- Xextern struct IntuitionBase *IntuitionBase;
- Xextern int openlibs();
- Xvoid *AllocMem();
- X
- X
- Xstruct Window *createwindow(screen, flags, idcmp, leftedge, topedge, width, height)
- X struct Screen *screen;
- X ULONG flags, idcmp;
- X int leftedge, topedge, width, height;
- X{
- X struct Window *OpenWindow();
- X int wb_height;
- X struct NewWindow *tempwin;
- X struct Window *win;
- X
- X /* some sanity checking - short and fast */
- X if(GfxBase == NULL || IntuitionBase == NULL)
- X if ( openlibs(GFX | INTUITION) == NULL)
- X return NULL;
- X
- X tempwin = (struct NewWindow *)AllocMem(sizeof(struct NewWindow), MEMF_CLEAR);
- X if (tempwin == NULL)
- X return NULL;
- X
- X if (width < 0) /* more checking */
- X width = GfxBase->NormalDisplayColumns;
- X if (height < 0)
- X height = 1500;
- X
- X tempwin->Flags = flags; tempwin->IDCMPFlags = idcmp;
- X tempwin->LeftEdge = (SHORT)leftedge; tempwin->Width = (SHORT)width;
- X tempwin->TopEdge = (SHORT)topedge; tempwin->Height = (SHORT)height;
- X tempwin->MinWidth = 60; tempwin->MinHeight = 30;
- X tempwin->DetailPen= -1; tempwin->BlockPen = -1;
- X tempwin->Type = WBENCHSCREEN;
- X tempwin->Screen = screen; /* if it's null that's o.k. too */
- X
- X /* if user has a custom screen, open up on that screen */
- X if (screen) {
- X tempwin->Type = CUSTOMSCREEN;
- X if (leftedge + width > screen->Width)
- X tempwin->Width = (screen->Width - leftedge);
- X
- X if (topedge + height > screen->Height)
- X tempwin->Height = (screen->Height - topedge);
- X }
- X else {
- X if (leftedge+width > GfxBase->NormalDisplayColumns)
- X tempwin->Width = (GfxBase->NormalDisplayColumns - leftedge);
- X
- X /* gotta make sure to check for interlace */
- X wb_height = (GfxBase->NormalDisplayRows * (1 + laced_wb()) );
- X if (topedge + height > wb_height )
- X tempwin->Height = wb_height - topedge;
- X }
- X
- X win = OpenWindow(tempwin);
- X
- X FreeMem(tempwin, sizeof(struct NewWindow));
- X return win;
- X} /* end of makewindow() */
- X
- X
- X
- X/* return TRUE (1) if wb screen is interlaced otherwise,
- X * we return FALSE (0) if it is NOT interlaced
- X */
- Xlaced_wb()
- X{
- X struct Preferences prefs;
- X
- X GetPrefs(&prefs, sizeof(struct Preferences));
- X if (prefs.LaceWB)
- X return 1;
- X else
- X return 0;
- X} /* end of laced_wb() */
- X
- X
- Xkillwindow(window)
- X register struct Window *window;
- X{
- X register struct IntuiMessage *msg, *GetMsg();
- X
- X if (window < 100)
- X return;
- X
- X /* make sure this is NULL if you have already cleared out your menus. */
- X if (window->MenuStrip != NULL)
- X ClearMenuStrip(window);
- X
- X /* make sure there aren't any junk messages hanging here */
- X while(window->UserPort != NULL && (msg = GetMsg(window->UserPort)) != NULL )
- X ReplyMsg(msg);
- X
- X /* then just close the window */
- X CloseWindow(window);
- X}
- X
- X/* this routine will make your standard Intuition Window. It creates
- X * a window with all the standard system gadgets on it, and makes it
- X * the appropriate size (with sanity checking)
- X */
- X
- Xstruct Window *makewindow(screen, leftedge, topedge, width, height)
- X struct Screen *screen;
- X int leftedge, topedge, width, height;
- X{
- X static ULONG idcmp = CLOSEWINDOW, /* IDCMP Classes */
- X /* system flags */
- X flags = WINDOWCLOSE|WINDOWDEPTH|WINDOWDRAG|WINDOWSIZING|NOCAREREFRESH|SMART_REFRESH|ACTIVATE;
- X
- X return (struct Window *)createwindow(screen, flags, idcmp, leftedge, topedge, width, height);
- X}
- X
- X
- END_OF_FILE
- if test 3360 -ne `wc -c <'src/window.c'`; then
- echo shar: \"'src/window.c'\" unpacked with wrong size!
- fi
- # end of 'src/window.c'
- fi
- echo shar: End of archive 1 \(of 2\).
- cp /dev/null ark1isdone
- MISSING=""
- for I in 1 2 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked both archives.
- rm -f ark[1-9]isdone
- else
- echo You still need to unpack the following archives:
- echo " " ${MISSING}
- fi
- ## End of shell archive.
- exit 0
- --
- Mail submissions (sources or binaries) to <amiga@uunet.uu.net>.
- Mail comments to the moderator at <amiga-request@uunet.uu.net>.
- Post requests for sources, and general discussion to comp.sys.amiga.
-